<template>
  <el-scrollbar>
    <div class="app-container">
      <div class="filter-container" size="small">
        <el-input
          v-model="listQuery.title"
          size="small"
          placeholder="标题"
          style="width: 200px"
          class="filter-item"
          clearable
        />

        <el-button
          class="filter-item"
          size="small"
          icon="el-icon-search"
          type="primary"
          plain
          @click="search()"
        >
          {{ $t('table.search') }}
        </el-button>

        <el-button
          size="small"
          class="filter-item right"
          icon="el-icon-refresh"
          type="primary"
          plain
          @click="refresh()"
        >
          刷新
        </el-button>
      </div>

      <el-table
        ref="multipleTable"
        v-loading="listLoading"
        :data="list"
        :height="
          listQuery.total > 0 ? 'calc(100vh - 205px)' : 'calc(100vh - 170px)'
        "
        :header-cell-style="{ background: '#F2F6FC' }"
        element-loading-text="Loading"
        fit
        border
        size="medium"
      >
        <el-table-column
          label="序号"
          width="50"
          type="index"
          align="center"
        ></el-table-column>

        <el-table-column label="验证码图" prop="codeImg" align="center">
          <!-- <el-image :src="CodeImg"></el-image> -->
          <!-- 图片的显示 -->
          <template slot-scope="scope">
            <img :src="scope.row.codeImg" />
          </template>
        </el-table-column>

        <el-table-column
          label="识别结果"
          prop="code"
          align="center"
        ></el-table-column>

        <el-table-column
          label="结果对错"
          prop="result"
          align="center"
        ></el-table-column>

        <el-table-column
          label="识别时间"
          prop="distinguishTime"
          align="center"
        ></el-table-column>

        <el-table-column
          label="买家数据拉取ID"
          prop="id"
          align="center"
        ></el-table-column>
      </el-table>
      <!--分页-->
      <pagination
        v-show="listQuery.total > 0"
        :total="listQuery.total"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.limit"
        @pagination="fetchData"
      />
    </div>
  </el-scrollbar>
</template>

<script>
import Pagination from '@/components/Pagination'
import { getAction } from '@/api/common'

export default {
  name: 'index',
  components: {
    Pagination,
  },
  data() {
    return {
      listLoading: true,
      list: [],
      // 列表搜索条件
      listQuery: {
        page: 1,
        total: 0,
        limit: 20,
        name: '',
        state: '',
      },
      rowData: {},
      showState: false,
      showViewState: false,
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    async fetchData() {
      this.listLoading = true
      const { data } = await getAction(this.listQuery, 'BuyerData/VerfityIndex')
      this.list = data.items
      this.listQuery.total = data.total
      this.listLoading = false
    },
    search() {
      this.listQuery.page = 1
      this.fetchData()
    },
    refresh() {
      this.fetchData()
    },
    closeAction() {
      this.showState = false
      this.showViewState = false
      this.fetchData()
    },
  },
}
</script>

<style scoped></style>
